package com.android.controller_bt;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.widget.ImageView;

public class MyImageView extends ImageView {
	private OnTouchListener listener;

	public MyImageView(Context context) {
		super(context);
	}

	public MyImageView(Context context, AttributeSet attrs, int defStyleAttr) {
		super(context, attrs, defStyleAttr);
	}

	public MyImageView(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	@Override
	public boolean onTouchEvent(MotionEvent event) {
		switch (event.getAction()) {
		case MotionEvent.ACTION_DOWN:
			if(listener != null){
				listener.actionDown(this);
			}
			break;
		case MotionEvent.ACTION_UP:
			if(listener != null){
				listener.actionUp(this);
			}
			break;
		}
		return super.onTouchEvent(event);
	}
	
	public void setOnTouchListener2(OnTouchListener listener){
		this.listener = listener;
	}

	public interface OnTouchListener {
		void actionDown(View view);
		void actionUp(View view);
	}

}
